package com.pro.framework.message;

import com.pro.framework.api.FrameworkConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class ApplicationMessageSender implements IApplicationMessageService {

    // 明确使用消息专用的RedisTemplate
    @Autowired
    @Qualifier(FrameworkConst.RedisTemplate.messageRedisTemplate)
    private RedisTemplate<String, Object> messageRedisTemplate;

    @Override
    public void sendMessageToServers(String topic, Object data) {
        // 使用专门为消息配置的Template（不带类型信息）
        messageRedisTemplate.convertAndSend(topic, data);
    }
}
